<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/13 0013
 * Time: 下午 4:05
 */
namespace app\common\lib;

use app\api\controller\Image;
use app\common\Helper;

class Wx{

    /**
     * 生成店铺二维码
     * @param $businessId
     * @param $storeId
     * @return bool|mixed
     */
    public static function getStoreCode($storeId){
        $access_token = WxTools::getAccessToken();
        $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $access_token;
        $postData["scene"] = $storeId;
        $postData["page"] = "pages/home/Home";
        $result = Helper::curlPost($url,json_encode($postData));
        $image = new Image();
        $res = $image->uploadstream($result);
        return $res;
    }

    public static function getTicketCode($id){
        $access_token = WxTools::getAccessToken();
        $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $access_token;
        $postData["scene"] = $id;
        $postData["page"] = "pages/activity/ActivityDetails";
        $result = Helper::curlPost($url,json_encode($postData));
        $image = new Image();
        $res = $image->uploadstream($result);
        return $res;
    }


}